@import "@@/styles/variables.scss";

// 修复滚动条问题
.app-container {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.main-content {
  display: flex;
  flex: 1;
  gap: 24px;
  overflow: hidden;
  min-height: 0; // 关键：允许flex子项收缩

  .left-panel {
    width: 400px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--el-bg-color, $background-color);
    border-radius: 8px;
    border: 1px solid var(--el-border-color, $border-color);
    min-height: 0; // 关键：允许flex子项收缩

    .search-box {
      padding: 16px;
      border-bottom: 1px solid var(--el-border-color-lighter, $border-light-color);
      flex-shrink: 0; // 防止搜索框被压缩
    }

    .list-header {
      padding: 16px;
      border-bottom: 1px solid var(--el-border-color-lighter, $border-light-color);
      flex-shrink: 0; // 防止标题被压缩

      h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: var(--el-text-color-primary, $secondary-text-color);
      }
    }

    .channel-list {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
      min-height: 0; // 关键：允许内容区域收缩

      .channel-card {
        padding: 16px;
        border: 1px solid var(--el-border-color, $border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        cursor: pointer;
        transition: all 0.2s;
        background: var(--el-bg-color, $background-color);

        &:hover {
          border-color: var(--el-color-primary, $primary-color);
          box-shadow: 0 2px 8px var(--el-color-primary-light-8, rgba(3, 2, 18, 0.1));
        }

        &.active {
          border-color: var(--el-color-primary, $primary-color);
          background-color: var(--el-color-primary-light-9, rgba(3, 2, 18, 0.05));
        }

        .card-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 12px;

          .channel-info {
            display: flex;
            align-items: center;
            gap: 8px;

            .channel-icon {
              color: var(--el-text-color-secondary, $secondary-color);
            }

            .channel-name {
              font-weight: 600;
              color: var(--el-text-color-primary, $secondary-text-color);
            }
          }

          .card-actions {
            display: flex;
            align-items: center;
            gap: 8px;
          }
        }

        .card-content {
          .info-item {
            display: flex;
            margin-bottom: 6px;
            font-size: 13px;

            .label {
              color: var(--el-text-color-secondary, $secondary-color);
              width: 70px;
              flex-shrink: 0;
            }

            .value {
              color: var(--el-text-color-primary, $secondary-text-color);
            }
          }
        }

        // 分页组件样式
        .pagination-container {
          margin-top: 20px;
          padding: 16px 0;
          border-top: 1px solid var(--el-border-color-lighter, $border-light-color);
          display: flex;
          justify-content: center;
          align-items: center;

          .el-pagination {
            --el-pagination-font-size: 14px;

            .el-pagination__total {
              color: var(--el-text-color-regular, $secondary-text-color);
            }

            .el-pagination__sizes {
              .el-select {
                .el-input__wrapper {
                  background-color: var(--el-bg-color, $background-color);
                  border-color: var(--el-border-color, $border-color);
                }
              }
            }

            .el-pagination__jump {
              color: var(--el-text-color-regular, $secondary-text-color);

              .el-input__wrapper {
                background-color: var(--el-bg-color, $background-color);
                border-color: var(--el-border-color, $border-color);
              }
            }
          }
        }
      }
    }
  }

  .right-panel {
    flex: 1;
    background: var(--el-bg-color, $background-color);
    border-radius: 8px;
    border: 1px solid var(--el-border-color, $border-color);
    overflow-y: auto;
    min-height: 0; // 关键：允许flex子项收缩

    .detail-content {
      padding: 24px;

      .detail-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--el-border-color-lighter, $border-light-color);

        h2 {
          margin: 0;
          font-size: 20px;
          font-weight: 600;
          color: var(--el-text-color-primary); /* 跟随主题的字体主题色 */
        }
      }

      .detail-section {
        margin-bottom: 32px;

        h3 {
          font-size: 16px;
          font-weight: 600;
          color: var(--el-text-color-primary); /* 跟随主题的字体主题色 */
          margin: 0 0 16px 0;
        }

        .section-row {
          display: grid;
          grid-template-columns: 1fr 1fr;
          gap: 80px 120px;
          margin-bottom: 24px;
          width: 100%;

          .info-group {
            display: flex;
            flex-direction: column;
            gap: 8px;

            label {
              font-size: 14px;
              color: var(--el-text-color-secondary); /* 跟随主题的次要字体主题色 */
              font-weight: 400;
              line-height: 1.2;
            }

            span {
              font-size: 16px;
              color: var(--el-text-color-primary); /* 跟随主题的字体主题色 */
              font-weight: 500;
              line-height: 1.2;
            }
          }
        }

        .agent-tree {
          .agent-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px;
            background-color: var(--el-fill-color-lighter, $background-secondary-color);
            border-radius: 8px;
            margin-bottom: 12px;
            border: none;
            transition: all 0.2s;

            &.level-two {
              background-color: var(--el-fill-color-lighter, $background-secondary-color);
            }

            &.level-three {
              background-color: var(--el-fill-color-lighter, $background-secondary-color);
              margin-left: 32px;
              margin-bottom: 8px;
            }

            .agent-info {
              display: flex;
              align-items: center;
              gap: 12px;

              .expand-icon {
                color: var(--el-text-color-secondary, $secondary-color);
                cursor: pointer;
                font-size: 16px;
                transition: all 0.2s;
                width: 16px;
                height: 16px;

                &:hover {
                  color: var(--el-color-primary, $primary-color);
                }
              }

              .agent-icon {
                font-size: 18px;
                width: 18px;
                height: 18px;

                &.blue {
                  color: var(--el-color-primary, $info-color);
                }

                &.green {
                  color: var(--el-color-success, $success-color);
                }
              }

              .agent-name {
                font-weight: 500;
                color: var(--el-text-color-primary, $secondary-text-color);
                font-size: 14px;
                margin-right: 12px;
              }
            }

            .agent-actions {
              display: flex;
              align-items: center;
              gap: 8px;
            }
          }

          .sub-agents {
            .agent-item.level-three {
              margin-bottom: 8px;
            }
          }

          .add-agent-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px;
            background-color: transparent;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            color: var(--el-text-color-secondary, $secondary-color);
            transition: all 0.2s;
            font-size: 14px;

            &:hover {
              background-color: var(--el-fill-color-extra-light, lighten($background-secondary-color, 2%));
              color: var(--el-color-primary, $primary-color);
            }

            &.level-three {
              margin-left: 32px;
              margin-top: 8px;
              margin-bottom: 16px;
              color: var(--el-text-color-secondary, $secondary-color);

              &:hover {
                background-color: var(--el-color-success-light-9, rgba(16, 185, 129, 0.1));
                color: var(--el-color-success, $success-color);
              }
            }

            .add-icon {
              font-size: 16px;
              width: 16px;
              height: 16px;
            }
          }
        }

        .empty-agents {
          text-align: center;
          padding: 40px;
          color: var(--el-text-color-secondary, $secondary-color);

          p {
            margin-bottom: 16px;
          }
        }
      }
    }

    .empty-detail {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      color: var(--el-text-color-secondary, $secondary-color);
    }
  }
}

// 自定义按钮样式
.theme-button {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;

  .button-icon {
    margin-right: 8px;
    font-size: 16px;
  }

  &--primary {
    background-color: $button-primary-bg;
    color: $button-primary-text;
    border-color: $button-primary-border;

    &:hover {
      background-color: $button-primary-hover-bg;
      border-color: $button-primary-hover-border;
    }

    .button-icon {
      color: $button-primary-text;
    }
  }

  &--secondary {
    background-color: $button-secondary-bg;
    color: $button-secondary-text;
    border-color: $button-secondary-border;

    &:hover {
      background-color: $button-secondary-hover-bg;
      border-color: $button-secondary-hover-border;
    }

    .button-icon {
      color: $button-secondary-text;
    }
  }

  &--small {
    padding: 6px 12px;
    font-size: 13px;

    .button-icon {
      font-size: 14px;
      margin-right: 6px;
    }
  }
}

// 主题按钮样式 - 跟随主题色
.theme-primary-button {
  background-color: var(--el-color-primary) !important; /* 跟随主题的主色调背景 */
  border-color: var(--el-color-primary) !important; /* 跟随主题的主色调边框 */
  color: var(--el-color-white) !important; /* 跟随主题的白色文字 */

  &:hover,
  &:focus {
    background-color: var(--el-color-primary-light-3) !important; /* 跟随主题的hover背景主题色 */
    border-color: var(--el-color-primary-light-3) !important; /* 跟随主题的hover边框主题色 */
    color: var(--el-color-white) !important; /* 保持白色文字 */
  }

  &:active {
    background-color: var(--el-color-primary-dark-2) !important; /* 跟随主题的按下状态背景 */
    border-color: var(--el-color-primary-dark-2) !important; /* 跟随主题的按下状态边框 */
  }

  // 确保图标颜色正确
  .el-icon {
    color: var(--el-color-white) !important; /* 跟随主题的白色图标 */
  }
}

// 滚动条样式
:deep(.channel-list::-webkit-scrollbar),
:deep(.right-panel::-webkit-scrollbar) {
  width: 6px;
}

:deep(.channel-list::-webkit-scrollbar-track),
:deep(.right-panel::-webkit-scrollbar-track) {
  background: var(--el-fill-color-lighter, $border-light-color);
  border-radius: 3px;
}

:deep(.channel-list::-webkit-scrollbar-thumb),
:deep(.right-panel::-webkit-scrollbar-thumb) {
  background: var(--el-border-color, $border-color);
  border-radius: 3px;
}

:deep(.channel-list::-webkit-scrollbar-thumb:hover),
:deep(.right-panel::-webkit-scrollbar-thumb:hover) {
  background: var(--el-text-color-secondary, $secondary-color);
}

// 分页组件样式
.pagination-container {
  padding: 12px 16px;
  border-top: 1px solid var(--el-border-color-lighter, $border-light-color);
  display: flex;
  justify-content: center;
  background: var(--el-bg-color, $background-color);
  border-radius: 0 0 8px 8px;

  .el-pagination {
    --el-pagination-font-size: 12px;

    // 紧凑型分页样式
    &.el-pagination--small {
      .el-pager {
        li {
          min-width: 24px;
          height: 24px;
          line-height: 24px;
          font-size: 12px;
          margin: 0 2px;

          &.is-active {
            background-color: var(--el-color-primary, $primary-color);
            color: #fff;
            font-weight: 500;
          }

          &:hover {
            color: var(--el-color-primary, $primary-color);
          }
        }
      }

      .btn-prev,
      .btn-next {
        min-width: 24px;
        height: 24px;
        line-height: 24px;
        font-size: 12px;
        color: var(--el-text-color-regular, $secondary-text-color);

        &:hover {
          color: var(--el-color-primary, $primary-color);
        }

        &.is-disabled {
          color: var(--el-text-color-placeholder);
        }
      }
    }
  }
}
